//引入config
// const { url } = require('../connfig')
module.exports = (message) => {
    let options = {
        toUserName: message.FromUserName,
        fromUserName: message.ToUserName,
        createTime: Date.now(),
        // msgType: message.MsgType,
        msgType: 'text'

    }


    let content = '请输入1或者2或者3'
        // 判断用户发送信息是文本内容
    if (message.MsgType === 'text') {
        if (message.Content === '1') {
            content = '欢迎关注贝莱福公众号';
        } else if (message.Content === '2') {
            content = '欢迎'
        } else if (message.Content.match('3')) { //半匹配
            content = '你好'
        }
    } else if (message.MsgType === 'image') {
        options.msgType = 'image';
        options.mediaId = message.MediaId;
        console.log(message.PicUrl);
    } else if (message.MsgType === 'voice') {
        options.msgType = 'voice';
        options.mediaId = message.MediaId;
        console.log(message.Recognition);
    } else if (message.MsgType === 'location') {
        options.msgType = 'location';
        content = `纬度:${message.Location_X} 经度:${message.Location_Y} 缩放大小:${message.Scale} 位置信息:${message.Label}`
    } else if (message.MsgType === 'event') {
        if (message.Event === 'subscribe') {
            content = '欢迎您的关注'
            if (message.EventKey) {
                content = '用户扫描了带参数的二维码关注事件'
            }
        } else if (message.Event === 'unsubscribe') {
            console.log('取消关注');
        } else if (message.Event === 'SCAN') {
            content = '用户已经扫描带参数的二维码关注事件'
        } else if (message.Event === 'LOCATION') {
            content = `纬度:${message.Latitude} 经度:${message.Longitude} 精度:${message.Precision}`
        } else if (message.Event === 'CLICK') {
            content = `你点击了:${message.EventKey}`
        }
    }

    options.content = content
    console.log(options);

    return options
}